#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
开放商户 - 商户信息DTO相关模型
"""

from typing import Dict, Any
from jlpay.utils.annotation_utils import Encrypt, SensitiveField


class MerchBaseInfoDto:
    """商户基本信息"""
    
    def __init__(self):
        """初始化商户基本信息"""
        self.apply_id = None
        self.product_type = None
    
    def set_apply_id(self, apply_id):
        """设置业务申请编号"""
        self.apply_id = apply_id
        return self
    
    def set_product_type(self, product_type):
        """设置产品基本类型"""
        self.product_type = product_type
        return self
    
    def to_dict(self) -> Dict[str, Any]:
        """转换为字典格式"""
        return {
            'apply_id': self.apply_id,
            'product_type': self.product_type
        }


class MerchBusinessInfoDto:
    """商户经营信息"""
    
    def __init__(self):
        """初始化商户经营信息"""
        self.merch_no = None
        self.merch_shortname = None
        self.unionpay_name = None
        self.wechat_name = None
        self.alipay_name = None
        self.address_code = None
        self.address_detail = None
        self.mcc_code = None
        self.cs_hotline = None
        self.door_pic = None
        self.cashier_pic = None
        self.indoor_pic = None
    
    def set_merch_no(self, merch_no):
        """设置商户号"""
        self.merch_no = merch_no
        return self
    
    def set_merch_shortname(self, merch_shortname):
        """设置商户经营名称"""
        self.merch_shortname = merch_shortname
        return self
    
    def set_unionpay_name(self, unionpay_name):
        """设置银联经营名称"""
        self.unionpay_name = unionpay_name
        return self
    
    def set_wechat_name(self, wechat_name):
        """设置微信经营名称"""
        self.wechat_name = wechat_name
        return self
    
    def set_alipay_name(self, alipay_name):
        """设置支付宝经营名称"""
        self.alipay_name = alipay_name
        return self
    
    def set_address_code(self, address_code):
        """设置经营地址-省市区"""
        self.address_code = address_code
        return self
    
    def set_address_detail(self, address_detail):
        """设置经营地址-详细地址"""
        self.address_detail = address_detail
        return self
    
    def set_mcc_code(self, mcc_code):
        """设置所属行业"""
        self.mcc_code = mcc_code
        return self
    
    def set_cs_hotline(self, cs_hotline):
        """设置客服电话"""
        self.cs_hotline = cs_hotline
        return self
    
    def set_door_pic(self, door_pic):
        """设置经营门头照"""
        self.door_pic = door_pic
        return self
    
    def set_cashier_pic(self, cashier_pic):
        """设置经营收银台"""
        self.cashier_pic = cashier_pic
        return self
    
    def set_indoor_pic(self, indoor_pic):
        """设置经营内景照"""
        self.indoor_pic = indoor_pic
        return self
    
    def to_dict(self) -> Dict[str, Any]:
        """转换为字典格式"""
        return {
            'merch_no': self.merch_no,
            'merch_shortname': self.merch_shortname,
            'unionpay_name': self.unionpay_name,
            'wechat_name': self.wechat_name,
            'alipay_name': self.alipay_name,
            'address_code': self.address_code,
            'address_detail': self.address_detail,
            'mcc_code': self.mcc_code,
            'cs_hotline': self.cs_hotline,
            'door_pic': self.door_pic,
            'cashier_pic': self.cashier_pic,
            'indoor_pic': self.indoor_pic
        }


@Encrypt  # 标记整个类需要加密处理
class MerchIdentificationInfoDto:
    """商户身份信息"""
    
    def __init__(self):
        """初始化商户身份信息"""
        self.license_name = None
        self.business_scope = None
        self.license_address = None
        self.period_begin = None
        self.period_end = None
        self.license_pic = None
        self.id_card_name = None
        self.id_card_english_name = None
        self.id_card_no = None
        self.legal_person_phone = None
        self.card_period_begin = None
        self.card_period_end = None
        self.id_card_copy = None
        self.id_card_national = None
        self.proof_info = None
        
        # 定义敏感字段路径（根据Java代码中的@Encrypt注解）
        self._sensitive_fields = [
            SensitiveField("id_card_name"),           # 经营者/法人姓名
            SensitiveField("id_card_english_name"),   # 经营者/法人英文名称
            SensitiveField("id_card_no"),             # 经营者/法人身份证件号码
            SensitiveField("legal_person_phone"),     # 经营者/法人手机号码
        ]
    
    def get_sensitive_fields(self):
        """
        返回需要加密的敏感字段路径列表
        
        Returns:
            包含敏感字段路径的列表
        """
        return self._sensitive_fields
    
    def set_license_name(self, license_name):
        """设置商户法定名称"""
        self.license_name = license_name
        return self
    
    def set_business_scope(self, business_scope):
        """设置经营范围"""
        self.business_scope = business_scope
        return self
    
    def set_license_address(self, license_address):
        """设置注册地址"""
        self.license_address = license_address
        return self
    
    def set_period_begin(self, period_begin):
        """设置有效期限开始日期"""
        self.period_begin = period_begin
        return self
    
    def set_period_end(self, period_end):
        """设置有效期限结束日期"""
        self.period_end = period_end
        return self
    
    def set_license_pic(self, license_pic):
        """设置营业证明影像"""
        self.license_pic = license_pic
        return self
    
    def set_id_card_name(self, id_card_name):
        """设置经营者/法人姓名"""
        self.id_card_name = id_card_name
        return self
    
    def set_id_card_english_name(self, id_card_english_name):
        """设置经营者/法人英文名称"""
        self.id_card_english_name = id_card_english_name
        return self
    
    def set_id_card_no(self, id_card_no):
        """设置经营者/法人身份证件号码"""
        self.id_card_no = id_card_no
        return self
    
    def set_legal_person_phone(self, legal_person_phone):
        """设置经营者/法人手机号码"""
        self.legal_person_phone = legal_person_phone
        return self
    
    def set_card_period_begin(self, card_period_begin):
        """设置证件有效期-开始时间"""
        self.card_period_begin = card_period_begin
        return self
    
    def set_card_period_end(self, card_period_end):
        """设置证件有效期结束时间"""
        self.card_period_end = card_period_end
        return self
    
    def set_id_card_copy(self, id_card_copy):
        """设置证件正面"""
        self.id_card_copy = id_card_copy
        return self
    
    def set_id_card_national(self, id_card_national):
        """设置证件反面"""
        self.id_card_national = id_card_national
        return self
    
    def set_proof_info(self, proof_info):
        """设置辅助证明材料"""
        self.proof_info = proof_info
        return self
    
    def to_dict(self) -> Dict[str, Any]:
        """转换为字典格式"""
        return {
            'license_name': self.license_name,
            'business_scope': self.business_scope,
            'license_address': self.license_address,
            'period_begin': self.period_begin,
            'period_end': self.period_end,
            'license_pic': self.license_pic,
            'id_card_name': self.id_card_name,
            'id_card_english_name': self.id_card_english_name,
            'id_card_no': self.id_card_no,
            'legal_person_phone': self.legal_person_phone,
            'card_period_begin': self.card_period_begin,
            'card_period_end': self.card_period_end,
            'id_card_copy': self.id_card_copy,
            'id_card_national': self.id_card_national,
            'proof_info': self.proof_info
        }


class MerchSettleInfoDto:
    """商户结算信息"""
    
    def __init__(self):
        """初始化商户结算信息"""
        self.settle_mode = None
        self.day_cut = None
        self.settle_session = None
        self.account_change_flag = None
        self.postscript = None
    
    def set_settle_mode(self, settle_mode):
        """设置结算方式"""
        self.settle_mode = settle_mode
        return self
    
    def set_day_cut(self, day_cut):
        """设置营业周期"""
        self.day_cut = day_cut
        return self
    
    def set_settle_session(self, settle_session):
        """设置结算场次"""
        self.settle_session = settle_session
        return self
    
    def set_account_change_flag(self, account_change_flag):
        """设置是否允许商户自主变更结算账户"""
        self.account_change_flag = account_change_flag
        return self
    
    def set_postscript(self, postscript):
        """设置结算附言"""
        self.postscript = postscript
        return self
    
    def to_dict(self) -> Dict[str, Any]:
        """转换为字典格式"""
        return {
            'settle_mode': self.settle_mode,
            'day_cut': self.day_cut,
            'settle_session': self.settle_session,
            'account_change_flag': self.account_change_flag,
            'postscript': self.postscript
        } 